<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src="plugins/jQuery/jQuery-2.2.0.min.js"></script>
<script type="text/javascript"
	src="http://api.map.baidu.com/api?v=2.0&ak=2Kdu1GZSiRWUQZLqPrD4hycyNaoLsVrO 	"></script>

<style type="text/css">
	#map label{max-width:none;}
</style>


<title>站点管理</title>

<meta
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
	name="viewport">
<!-- Bootstrap 3.3.6 -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/bootstrap/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet"
	href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet"
	href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/dist/css/AdminLTE.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/dist/css/theme.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/dist/css/skins/_all-skins.min.css">
<!-- iCheck -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/iCheck/flat/blue.css">
<!-- Morris chart -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/morris/morris.css">
<!-- jvectormap -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-1.2.2.css">
<!-- Date Picker -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/datepicker/datepicker3.css">
<!-- Daterange picker -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker-bs3.css">
<!-- bootstrap wysihtml5 - text editor -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/dist/css/theme.css"
	media="all">
	


</head>

<body class="hold-transition skin-blue sidebar-mini"
	style="font-family:Microsoft YaHei;">
	<div class="wrapper">

		<header class="main-header">
			<!-- Logo -->
			<div class="logo" style="background-color:#ec7500;">
				<!-- logo for regular state and mobile devices -->
				<span class="logo-lg"><b
					style="font-size:18px;margin-left:-40px ">厂车管理系统</b> </span>
			</div>
			<!-- Header Navbar: style can be found in header.less -->
			<nav class="navbar navbar-static-top"
				style="background-color:#ec7500;">
				<!-- Sidebar toggle button-->
				<a href="#" class="sidebar-toggle" data-toggle="offcanvas"
					role="button"> <span class="sr-only">Toggle navigation</span> </a>

				<div class="navbar-custom-menu">
					<ul class="nav navbar-nav">
						<!-- User Account:-->
						<li class="dropdown user user-menu"><span class="hidden-xs"></span>
						</li>
						<li style="color:#ffffff; background:#959595;padding:15px">${sessionScope.CurrentUser.username}</li>
						<li><a><i class="fa fa-sign-out"></i> </a>
						</li>
					</ul>
				</div>
			</nav>
		</header>
		<!-- Left side column. contains the logo and sidebar -->
		<aside class="main-sidebar">
			<!-- sidebar: style can be found in sidebar.less -->
			<section class="sidebar">
				<!-- sidebar menu: : style can be found in sidebar.less -->
				<ul class="sidebar-menu">
		<c:forEach var = "UserRoleActionsId"  items = "${sessionScope.CurrentUserActionsId}">
		  <c:choose>
		    <c:when test ="${UserRoleActionsId == 4 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/showEmps.do"> <i
					class="fa fa-user"></i><span>员工管理</span>
					 </a></li>
					 </c:when>
					 <c:when test ="${UserRoleActionsId == 8 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/showBuses.do"> <i class="fa fa-bus"></i>
					<span>车辆管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 12 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/carschedule_all.do"> <i class="fa fa-calendar"></i>
					<span>排班管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 16 }">
			<li class="active treeview"><a href="${pageContext.request.contextPath}/pages/stationManage.jsp"> <i
					class="fa fa-map-marker"></i> <span>站点管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 20 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/pages/lineManage.jsp"> <i class="fa fa-road"></i>
					<span>线路管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 24 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/findUserFirstPage.do"> <i class="fa fa-user-plus"></i>
					<span>用户管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 28 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/findRoleFirstPage.do"> <i
					class="fa fa-check-square-o"></i> <span>角色管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 32 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/pages/dataSave.jsp"> <i class="fa fa-save"></i>
					<span>数据备份</span> </a></li>
					</c:when>
					</c:choose></c:forEach>
		</ul>
			</section>
			<!-- /.sidebar -->
		</aside>

		<!-- Content Wrapper. Contains page content -->
		<div class="content-wrapper" style="background-color:#f2f2f2;">
			<!-- Main content -->
			<section class="content" style="padding:0px;margin:0px;">

				<div class="map" id="map">
				<div id="test"></div>

					<%-- <div
					style="right:100px;
	top:50px; width:380px;position:absolute;">
					<div>
						<button class="addsl" data-toggle="modal" data-target="#modifyroute"
							style="position:relative; left:-123px;top:39px;">修改线路</button>
						<button class="addsl" data-toggle="modal" data-target="#addroute">增加线路</button>
						<a style="margin-left:8px;"><img
							src="${pageContext.request.contextPath}/dist/img/export.png">
						</a> <a style="float:right;"><img
							src="${pageContext.request.contextPath}/dist/img/showStation0.png">
						</a>
					</div>
					<form id='stationSearchForm' style="margin-top:20px;"
						action='${pageContext.request.contextPath}/getStationInfo.do'>
						<input type="text" value="输入站点" class="form-control"
							id="navbar-search-input"
							style="background:#ffffff;color:#666; width:290px; margin-left:50px;">
						<a style="color:#ffffff;cursor:pointer;" data-toggle="modal"
							data-target="#myModal"><button class="btn btn-info"
								id="bstationSearch" name="query"
								style="background:#ff9900;border:none;float:right;margin-top:-33px;heigt:37px;">
								<i class="fa   fa-search" style="color:#fffff;"></i>
							</button> </a>
					</form>

				</div> --%>
				</div>
				<!-- addroute -->
						<div class="modal fade" id="addroute" tabindex="-1" role="dialog"
					aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content"
							style="width:400px;height:470px;position:relative; top:50px;left:100px;">
							<div class="modal-header"
								style="color:#ffffff;background:#ff9900;">
								<button type="button" class="close" data-dismiss="modal"
									aria-hidden="true">
									<i class="fa  fa-close " style="color:#ffffff"></i>
								</button>
								<h4 class="modal-title" id="myModalLabel">添加站点</h4>
							</div>
							<div class="modal-body" style="margin-top:50px;">
								<form id='locStationForm' class="form-horizontal" role="form"
									action='${pageContext.request.contextPath}/saveStation.do'
									method='post'>
									<div class="form-group" style="margin-left:30px; ">
										<label for="lastname" class="col-sm-4 control-label">站点地址</label>
										<div class="col-sm-6">
											<input type="text" class="form-control" id="station_loc"
												name="station_location"
												style="background:none;border:1px solid #bcbcbc;color:#000000;"
												placeholder="请输入姓">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="lastname" class="col-sm-4 control-label">站点名称</label>
										<div class="col-sm-6">
											<input type="text" class="form-control" name="station_name"
												id="station_name"
												style="background:none;border:1px solid #bcbcbc;color:#000000;"
												placeholder="请输入姓">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-4 control-label">站点乘车人数</label>
										<div class="col-sm-6">
											<input type="text" class="form-control" name="station_num" id="station_num"
												style="background:none;border:1px solid #bcbcbc;color:#000000;"
												placeholder="请输入名字">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-4 control-label">城市</label>
										<div class="col-sm-6">
											<input type="text" class="form-control" name="station_num"
												style="background:none;border:1px solid #bcbcbc;color:#000000;"
												placeholder="请输入名字">
										</div>
									</div>

									<input type="hidden" id="point" name="coordinate">


								</form>
							</div>
							<div class="modal-footer" style="padding:0 34%; margin-top:30px;">
								<button type="button" class="btn btn-default" id="blocStation"
									style="color:#ffffff;background:#ff9900;">保&nbsp;存</button>
								<button type="button" class="btn btn-default"
									data-dismiss="modal" style="color:#ffffff;background:#a0a0a0;">取&nbsp;消
								</button>
							</div>
						</div>
						<!-- /.modal-content -->
					</div>
					<!-- /.modal -->
				</div>
<!-- /.search-->
<!-- 弹出框修改 -->
<div class="modal fade" id="modifyroute" tabindex="-1" role="dialog"
					aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog">
					<div class="modal-content"
						style="width:400px;height:470px;position:relative; top:50px;left:100px;">
						<div class="modal-header"
							style="color:#ffffff;background:#ff9900;">
							<button type="button" class="close" data-dismiss="modal"
								aria-hidden="true">
								<i class="fa  fa-close " style="color:#ffffff"></i>
							</button>
							<h4 class="modal-title" id="myModalLabel">修改站点</h4>
						</div>
						<div class="modal-body">
							<div style="margin-bottom:30px;">
								<form id="searchBeforeUpForm">
									<input type="text" value="输入站点" class="form-control"
										id="navbar-search-input" name="station_name"
										style=";color:#666; width:200px; margin-left:50px;border:1px solid #ff9900; background:none;">
									<a style="color:#ffffff;cursor:pointer;"><button type="button"
											class="btn btn-info" id="bsearchBeforeUp" 
											style="background:#ff9900;border:none;float:right;margin-top:-33px;margin-right:55px;heigt:37px;">
											<i class="fa   fa-search" style="color:#fffff;"></i>
										</button>
										 </a>
								</form>
							</div>
							<form id="upStationForm" class="form-horizontal" role="form" >
								<input type="hidden" id="upStationId" name="station_id">
								<div class="form-group" style="margin-left:30px; ">
									<label for="lastname" class="col-sm-4 control-label">站点地址</label>
									<div class="col-sm-6">
										<input type="text" class="form-control" id="upStaionLoc"
											name="station_location"
											style="background:none;border:1px solid #bcbcbc;color:#000000;"
											placeholder="请输入姓">
									</div>
								</div>
								<div class="form-group" style="margin-left:30px;">
									<label for="lastname" class="col-sm-4 control-label">站点名称</label>
									<div class="col-sm-6">
										<input type="text" class="form-control" name="station_name"
											id="upStationName"
											style="background:none;border:1px solid #bcbcbc;color:#000000;"
											placeholder="请输入姓">
									</div>
								</div>
								<div class="form-group" style="margin-left:30px;">
									<label for="firstname" class="col-sm-4 control-label">站点乘车人数</label>
									<div class="col-sm-6">
										<input type="text" class="form-control" name="station_num" id="upStationNum"
											style="background:none;border:1px solid #bcbcbc;color:#000000;"
											placeholder="请输入名字">
									</div>
								</div>
								<div class="form-group">
									<label for="firstname" class="col-sm-5 control-label">实际站点乘车人数</label>
									<div class="col-sm-6">
										<input type="text" class="form-control" name="real_num" id="upStationRealNum"
											style="background:none;border:1px solid #bcbcbc;color:#000000; margin-left:-3px;"
											placeholder="请输入名字">
									</div>
								</div>
								


							</form>
						</div>
						<div class="modal-footer" style="padding:0 34%; margin-top:30px;">
							<button type="button" class="btn btn-default" id="bupStation"
								style="color:#ffffff;background:#ff9900;">保&nbsp;存</button>
							<button type="button" class="btn btn-default"
								data-dismiss="modal" style="color:#ffffff;background:#a0a0a0;">取&nbsp;消
							</button>
						</div>
					</div>
					<!-- /.modal-content -->
				</div>
				</div>
				<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
					aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content"
							style="width:330px;height:350px;position:relative; top:180px;left:495px;">
							<div class="modal-header" style="background:#ffffff;">
								<button type="button" class="close" data-dismiss="modal"
									aria-hidden="true">
									<i class="fa  fa-close " style="color:#ff9900"></i>
								</button>

							</div>
							<div class="modal-body">
								<table class="table table-bordered">
									<tr style="background:#ff9900;color:#ffffff;text-align:center;">
										<td>站点人数</td>
										<td>实际人数</td>
									</tr>
									<tr style=text-align:center;">
										<td id="the_station_num"></td>
										<td id="real_num"></td>
									</tr>
								</table>
								<table class="table table-bordered">
									<tr style="background:#ff9900;color:#ffffff;text-align:center;">
										<td colspan="4">乘车人员</td>
									</tr>
									<tr style=text-align:center;">
										<td id="employeeName"></td>
										
									</tr>
								</table>
							</div>

						</div>
						<!-- /.modal-content -->
					</div>
					<!-- /.modal -->
				</div>
			</section>
			<!-- /.content -->
		</div>
		<!-- /.content-wrapper -->

		<!-- ./wrapper -->

		<!-- jQuery 2.2.0 -->
		<script
			src="${pageContext.request.contextPath}/plugins/jQuery/jQuery-2.2.0.min.js"></script>
		<!-- jQuery UI 1.11.4 -->
		<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
		<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
		<script>
			$.widget.bridge('uibutton', $.ui.button);
		</script>
		<!-- Bootstrap 3.3.6 -->
		<script
			src="${pageContext.request.contextPath}/bootstrap/js/bootstrap.min.js"></script>
		<!-- Morris.js charts -->
		<script
			src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
		<script
			src="${pageContext.request.contextPath}/plugins/morris/morris.min.js"></script>
		<!-- Sparkline -->
		<script
			src="${pageContext.request.contextPath}/plugins/sparkline/jquery.sparkline.min.js"></script>
		<!-- jvectormap -->
		<script
			src="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
		<script
			src="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
		<!-- jQuery Knob Chart -->
		<script
			src="${pageContext.request.contextPath}/plugins/knob/jquery.knob.js"></script>
		<!-- daterangepicker -->
		<script
			src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.2/moment.min.js"></script>
		<script
			src="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker.js"></script>
		<!-- datepicker -->
		<script
			src="${pageContext.request.contextPath}/plugins/datepicker/bootstrap-datepicker.js"></script>
		<!-- Bootstrap WYSIHTML5 -->
		<script
			src="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
		<!-- Slimscroll -->
		<script
			src="${pageContext.request.contextPath}/plugins/slimScroll/jquery.slimscroll.min.js"></script>
		<!-- FastClick -->
		<script
			src="${pageContext.request.contextPath}/plugins/fastclick/fastclick.js"></script>
		<!-- AdminLTE App -->
		<script src="${pageContext.request.contextPath}/dist/js/app.min.js"></script>
		<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
		<script
			src="${pageContext.request.contextPath}/dist/js/pages/dashboard.js"></script>
		<!-- AdminLTE for demo purposes -->
		<script src="${pageContext.request.contextPath}/dist/js/demo.js"></script>
		<script src="${pageContext.request.contextPath}/dist/js/jquery.min.js"></script>
</body>
</html>
<script type="text/javascript">
	// 百度地图API功能
	var map = new BMap.Map("map", {
		enableMapClick : false
	});
	var point = new BMap.Point(116.400244, 39.92556);
	map.centerAndZoom(point, 12);
	map.enableScrollWheelZoom();
	var myGeo = new BMap.Geocoder(); 
	var marker;
	var stationInfo = "<form id='stationForm' action='${pageContext.request.contextPath}/saveStation.do' method='post'>站点信息<br/>站点名称：<input type='hidden' id='coordinate' name='coordinate' value=''><input type='text' id='station_name' name='station_name'><br />站点地址：<input type='text' id='station_location' name='station_location'><br/>站点人数：<input type='text' name='station_num'><br/><input type = 'button' id='bStationForm' value='确定' onclick='confirm()'><input type='button' value='取消' onclick='cancel()''></form>";
	var opts = {
		width : 250,
		height : 140,
		enableCloseOnClick : false

	}

	map.addEventListener("click", function(e){
		if(!e.overlay){
			var point = new BMap.Point(e.point.lng, e.point.lat);
			addMark(point);
		}
	});

	

	function addMark(point) {
		marker = new BMap.Marker(point);
		map.addOverlay(marker);
		var infoWindow = new BMap.InfoWindow(stationInfo, opts);
		infoWindow.disableCloseOnClick();
		map.openInfoWindow(infoWindow, point);
		myGeo.getLocation(point, function(result){      
		if (result){      
				$("#station_location").val(result.address);      
			}      
		});
		

	}

	function confirm() {

		document.getElementById('coordinate').value = marker.getPosition().lng
				+ "|" + marker.getPosition().lat;

		var ajax_url = $("#stationForm").attr('action');
		var ajax_type = $("#stationForm").attr('method');
		var ajax_data = $("#stationForm").serialize();

		$
				.ajax({
					type : ajax_type, //发送请求的方式，一般为post或者是get
					url : ajax_url, //请求服务器的组件地址
					data : ajax_data,
					success : function(msg, status) { //服务器成功响应客户端时回调该函数
						if (status == "success") {
							var staName = document
									.getElementById("station_name").value;
							var label = new BMap.Label(staName, {
								offset : new BMap.Size(20, -10)
							});
							marker.setLabel(label);
							map.closeInfoWindow();
							
						}
					}
				});

	}
	
	

	function cancel() {
		map.closeInfoWindow();
		map.removeOverlay(marker);
	}
	
	$("#map").append("<div style='right:100px; top:50px; width:380px;position:absolute;'> <div><button class='addsl' data-toggle='modal' data-target='#modifyroute' style='position:relative; left:-123px;top:39px;'>修改站点</button><button class='addsl' data-toggle='modal' data-target='#addroute'>增加站点</button><a style='margin-left:8px;'><img src='${pageContext.request.contextPath}/dist/img/export.png'></a> <a style='float:right;'><img id='onloadStation' src='${pageContext.request.contextPath}/dist/img/showStation0.png'></a></div><form id='stationSearchForm' style='margin-top:20px;' action='${pageContext.request.contextPath}/getStationInfo.do'><input type='text' name='station_name' value='输入站点' class='form-control'id='navbar-search-input'style='background:#ffffff;color:#666; width:290px; margin-left:50px;'><a style='color:#ffffff;cursor:pointer;' data-toggle='modal' data-target='#myModal'><button class='btn btn-info' id='bstationSearch' name='query' style='background:#ff9900;border:none;float:right;margin-top:-33px;heigt:37px;'><i class='fa   fa-search' style='color:#fffff;'></i></button> </a></form></div>");
	
	$("#bstationSearch").click(function(){
		var ajax_url = $("#stationSearchForm").attr('action');
		var ajax_type = $("#stationSearchForm").attr('method');
		var ajax_data = $("#stationSearchForm").serialize();
		
		$.ajax({
					type : ajax_type, //发送请求的方式，一般为post或者是get
					url : ajax_url, //请求服务器的组件地址
					data : ajax_data,
					success : function(msg, status) { //服务器成功响应客户端时回调该函数
						if (status == "success") {
							$("#the_station_num").text(msg.station_num);
							$("#real_num").text(msg.real_num);
							$("#employeeName").text(msg.employeeName);
						}
					}
				});
	
	});
	
	
	$("#blocStation").click(function(){
		var station_loc = $("#station_loc").val();
		myGeo.getPoint(station_loc,function(point){
			if(point){
				var stationName = $("#station_name").val();
				var stationNum = $("#station_num").val();
				$("#point").val(point.lng+"|"+point.lat);
				var ajax_data = $("#locStationForm").serialize();
				$.ajax({
					type:"post",
					url:"${pageContext.request.contextPath }/saveStation.do",
					data:ajax_data,
					success: function(msg){
						alert("添加站点成功了");
						var newMarker = new BMap.Marker(new BMap.Point(point.lng,point.lat));
						map.addOverlay(newMarker);
						var label = new BMap.Label(stationName, {
								offset : new BMap.Size(20, -10)
							});
						newMarker.setLabel(label);
						
						newMarker.addEventListener("click",function(){
							checkStaInfo(this,stationName,station_loc,stationNum,0);
						});
					}
				});
			}
		},"北京市");
	
	});
	
	function checkStaInfo(thisMarker,name,loc,num,realNum){
		
		var sContent1 = 
		'站点名称：'+name+'<br/>'
		+'站点地址：'+loc+'<br/>'
		+'站点乘车人数：'+num+'<br/>'
		+'实际乘车人数：'+realNum+'<br/>';
		
		var infoWindow = new BMap.InfoWindow(sContent1);
		thisMarker.openInfoWindow(infoWindow);
	}

	$(document).ready(
		$.ajax({
			type:"POST",
			url:"${pageContext.request.contextPath}/findAllStation.do",
			success:function(message,status){
				if(status == "success"){
					var stations = message;
					setStationMessage(stations);
				}
			}
		})
	);
	

	$("#onloadStation").click(function(){
	
		$.ajax({
			type:"POST",
			url:"${pageContext.request.contextPath}/findAllStation.do",
			success:function(message,status){
				if(status == "success"){
					var stations = message;
					setStationMessage(stations);
				}
			}
		
		});
	});
	
	
	
	
	function setStationMessage(stations){		
		for(var i = 0; i < stations.length; i++){
			var strPoint = stations[i].coordinate;
			var point = strPoint.split("|");
			var mapPoint = new BMap.Point(point[0],point[1]);
			var pointMarker = new BMap.Marker(mapPoint);
			map.addOverlay(pointMarker);
			var label = new BMap.Label(stations[i].station_name, {
								offset : new BMap.Size(20, -10)
							});
			
			
			pointMarker.setLabel(label);
			(function(){
				var station = stations[i];
				pointMarker.addEventListener("click",function(){
					showStationInfo(this,station);
				});
				pointMarker.addEventListener("rightclick",function(){
					delectStation(station.station_name,this);
					
				})
			})();
		}
	}
	function showStationInfo(thisMarker,station){
		var stationName = station.station_name;
		var sContent = 
		'站点名称：'+station.station_name+'<br/>'
		+'站点地址：'+station.station_location+'<br/>'
		+'站点乘车人数：'+station.station_num+'<br/>'
		+'实际乘车人数：'+station.real_num+'<br/>';
		var infoWindow = new BMap.InfoWindow(sContent);
		thisMarker.openInfoWindow(infoWindow);
	}
	function delectStation(staName,marker){
		$.ajax({
			type : "post", //发送请求的方式，一般为post或者是get
			url : "${pageContext.request.contextPath}/delectStation.do", //请求服务器的组件地址
			data : "stationName="+staName,
			success : function(msg, status) { //服务器成功响应客户端时回调该函数
				if (status == "success") {
					alert("该站点已删除！");
					map.removeOverlay(marker);	
				}
			}
		
		});
	
	}
	
	$("#bsearchBeforeUp").click("click",function(){
		var ajax_data = $("#searchBeforeUpForm").serialize();
		var ajax_url = "${pageContext.request.contextPath}/getStation.do";
		var ajax_type = "post";
		$.ajax({
			type : ajax_type,
			url : ajax_url,
			data : ajax_data,
			success : function(msg,status){
				if(status == "success"){
					$("#upStationId").val(msg.station_id);
					$("#upStaionLoc").val(msg.station_location);
					$("#upStationName").val(msg.station_name);
					$("#upStationNum").val(msg.station_num);
					$("#upStationRealNum").val(msg.real_num);
				}
			} 
		});
	
	});
	
	$("#bupStation").click("click",function(){
		var ajax_data = $("#upStationForm").serialize();
		var ajax_url = "${pageContext.request.contextPath}/updateStation.do";
		var ajax_type = "get";
		$.ajax({
			type : ajax_type,
			url : ajax_url,
			data : ajax_data,
			success : function(msg,status){
				if(status == "success"){
				
					alert("修改成功");
				}
			} 
		});
	
	});
	

</script>